/**
 * Created by zogod on 17/2/17.
 */

function insertJS(ref, file_path) {
  var fun1 = function () {
    $.ajax({
      type: "GET",
      url: file_path,
      dataType: "text",
      success: function (msg) {
        ref.executeScript({code: msg}, function () {
          //alert("Code Inserted Succesfully");
          ref.show();
        });
      },
      error: function () {
        alert("Ajax Error");
      }
    });
  };
  var fun2 = function () {
    setTimeout(fun1,1000);
  };
  ref.addEventListener('loadstop', fun2);
}

function insertCSS(ref, file_path) {
  ref.addEventListener('loadstop', function () {
    $.ajax({
      type: "GET",
      url: file_path,
      dataType: "text",
      success: function (msg) {
        ref.insertCSS({code: msg}, function () {
          //alert("Code Inserted Succesfully");
          ref.show();
        });
      },
      error: function () {
        alert("Ajax Error");
      }
    });
  });
}
